package com.xywy.common.app;

import android.content.Context;
import android.content.SharedPreferences;
import android.util.DisplayMetrics;
import android.view.WindowManager;

/**
 * 存储一设备信息，可能还会有更多字段加入
 * 初始化在loadingPageActivity的onCreate方法中
 * Created by xgd on 14-4-29.
 */
public class DeviceInfo {

    public static String UUID;  //客户端唯一标识
    public static int WIDTH;    //屏幕宽度
    public static int HEIGHT;   //屏幕高度

    public static void init(Context context){
        //获取设备唯一标识
        String uuid="android_"+java.util.UUID.randomUUID().toString().replace("-","");
        //存入本地 SharedPreferences
            SharedPreferences sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
            UUID = sp.getString("UUID","");
            if (UUID.equals("")){
                SharedPreferences.Editor editor = sp.edit();
                UUID = uuid;
                editor.putString("UUID",UUID);
                editor.commit();
            }
        //分辨率信息
        DisplayMetrics dm = new DisplayMetrics();
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        wm.getDefaultDisplay().getMetrics(dm);
        WIDTH = dm.widthPixels;
        HEIGHT = dm.heightPixels;
    }
}
